*Analysis Do-File for creating Figures 6
	*Figures are separated in to 6a,b,c,d
*Runs event study regressions and produces graphs of effects over time

***File set-up
macro drop _all
mat drop _all
eststo clear
estimates clear
global path "[ENTER PATH HERE]"
global figs "$path\REStat Replication V2\Figures"
global log "$path\REStat Replication V2\Log Files"
set scheme lean2

clear
set more off

cap log close
log using "$log\figure_6.txt", replace text
use "$path\REStat Replication V2\Data\master_data_analysis_subset"

*Set folder for main figures
cd "$figs"



***Loops through crime types, producing the estimates that go into Figure 6
foreach var of varlist index_violent murder_tot agg_assault_tot robbery_tot {
	
	***Analysis by qtr for extended event window
	di "------Reg `var' crime w/ no arrest missing------"
	reghdfe ln_actual_`var' ln_pop_s ///
		qtr_neg4_binned-qtr_neg2  qtr_0-qtr_6_binned ///
		if !inlist(., ln_`var', ln_actual_index_violent, ln_actual_index_property) ///
		, cl(group_ori) absorb(group_ori month_year)
			
	*Call plot code
	qui do "$path\REStat Replication\Code\coef_plot_quart"
			
	*Plot the normalized coefficents and SEs
	*Normalized to the negative first event (right before PK)
	*Plot with different y-axis depending on ori
	qui coefplot mat(coef_1000[,1]), vertical yline(0) se(2)  /// 
		yscale(range(-0.1 0.3))  ylabel(-0.1(0.1)0.3, glcolor(gs12)) ///
		msize(large) msymbol(O) mfcolor(black%100) mcolor(white%0) ///
		xtitle(Quarter Relative to Event) ytitle(Log Points) ///
		xline(3.5, lpattern(dash) lcolor(red) axis(1))
	
	if "`var'" == "index_violent" {
		graph export "figure_6a.pdf", replace
	}
	else if "`var'" == "murder_tot" {
		graph export "figure_6b.pdf", replace
	}
	else if "`var'" == "agg_assault_tot" {
		graph export "figure_6c.pdf", replace			
	}
	else if "`var'" == "robbery_tot" {
		graph export "figure_6d.pdf", replace			
	}	
}


cap log close

